<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" />
		<title></title>
		<style type="text/css">
			* {
				margin: 0;
				padding: 0;
			}

			#wrap {
				height: 100px;
				background: rgba(0, 0, 0, .5);
				position: relative;
			}

			#wrap #bg {
				position: absolute;
				left: 0;
				right: 0;
				bottom: 0;
				top: 0;
				background: url(bg.jpg) no-repeat;
				background-size: 100% 100%;
				z-index: -1;
			}

			img {
				margin: 24px 0 0 24px;
			}
			
			/*初始包含块下的盒子居中*/
			#test{
				position: absolute;
				left: 0;
				right: 0;
				bottom: 0;
				top: 0;
				margin: auto;
				width: 100px;
				height: 100px;
				background: pink;
				text-align: center;
				line-height: 100px;
			}
			
			html, body{
				height: 100%;
			}
			body{
				text-align: center;
			}
			body:after{
				content: "";
				display: inline-block;
				height: 100%;
				vertical-align: middle;
			}
			img{
				vertical-align: middle;
			}
		</style>
	</head>
	<body>
		<div id="wrap">
			<img src="bg.jpg" width="64px" height="64px">
			<div id="bg"></div>
		</div>
	</body>
</html>
